using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
namespace KLib.Graphics
{
    public class Sprite : IPositionable, IDrawable, IRotatable
    {
        #region Fields
        private string name;
        private Texture2D texture;

        private Vector2 size;
        private Vector2 position;
        private float rotation;
        private Vector2 scale;
        #endregion

        #region Properties
        /// <summary>
        /// Gets or Sets the Name of the Sprite
        /// </summary>
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public Texture2D Texture
        {
            get { return texture; }
            set 
            { 
                texture = value;
                size = new Vector2(texture.Width, texture.Height);
            }
        }

        public Vector2 Position
        {
            get { return position; }
            set { position = value; }
        }

        public float Rotation
        {
            get { return rotation; }
            set { rotation = value; }
        }

        public Vector2 Size
        {
            get { return size; }
            set { size = value; }
        }
        #endregion

        #region Initialization
        public Sprite() { }
        public Sprite(Texture2D texture, Vector2 position)
        {
            this.Texture = texture;
            this.position = Vector2.Zero;
        }
        #endregion

        #region Methods
        public void Move(Vector2 amount)
        {
            position.X += amount.X;
            position.Y += amount.Y;
        }

        public void MoveTo(Vector2 position)
        {
            this.position.X = position.X;
            this.position.Y = position.Y;
        }
        #endregion

        #region IDrawable Members

        public void Draw(SpriteRenderer spriteBatch)
        {
            spriteBatch.Draw(this);
        }

        #endregion

        #region IRotatable Members

        public void Rotate(float radians)
        {
            this.Rotation += radians;
        }

        public void RotateTo(float radians)
        {
            this.Rotation = radians;
        }

        #endregion
    }
}
